package com.yyj.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yyj.dao.OrderDao;
import com.yyj.dao.UserDao;
import com.yyj.domain.Goods;
import com.yyj.domain.Marange;
import com.yyj.domain.Order;
import com.yyj.domain.User;
import com.yyj.domain.WaitPay;
import com.yyj.service.UserService;


@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{
	
	@Autowired
	private UserDao userDao;

	
	@Override
	public int createUser(User user) {
		return this.userDao.createUser(user);
	}

	@Override
	public int updateUser(User user) {
		return this.userDao.updateUser(user);
	}

	@Override
	public boolean login(String account, String password) {
		User user = userDao.getUserByaccount(account);// 调用DAO，根据账号查找用户
		if (user != null) {
			if (password.equals(user.getPassword())) {// 密码也匹配
				return true;
			}
		}
		return false;
	}

	@Override
	public User getUserByaccount(String account) {
		 return userDao.getUserByaccount(account);
	}
	//查询待支付商品
	public List<WaitPay> selectWaitPay(String account) {
		return userDao.selectWaitPay(account);
	}
	
	
	//查询订单
	@Override
	public List<Order> selectOrder(String account) {
		return userDao.selectOrder(account);
	}
	//个人中心去支付
	public WaitPay selectMyPAy(int waitpay_id) {
		return userDao.selectMyPAy(waitpay_id);
	}

	//再次购买
	public Goods selectMyBuy(String goods_id) {
		return userDao.selectMyBuy(goods_id);
	}

	//从待支付表中删除
	public int delectwpuser(Integer waitpay_id) {
		
		return userDao.delectwpuser(waitpay_id);
	}
	//从订单表中删除
	public int delectorderuser(Integer order_id) {
		return userDao.delectorderuser(order_id);
	}

	
	
	//管理登录
	@Override
	public Marange selectMarange(Marange marange) {
		return userDao.selectMarange(marange);
	}
}
